<?php
namespace app\controller\admin;

use app\base\BaseEncryptController;
use app\model\system\SysRecycleModel;

/**
 * 回收站
 * Class SysRecycle
 * @package app\controller
 */
class SysRecycle extends BaseEncryptController
{
    /**
     * 分页列表
     * @param string $keyword
     * @param int $page
     * @param int $limit
     * @return \think\response\Json
     */
    public function getPage($keyword='',$page=1,$limit=10)
    {
        $db_recycle = new SysRecycleModel();
        $data = $db_recycle->getPageData($keyword,$page,$limit,'id,model_name,path,primary_key,desc,op_uid,op_utype,create_time');
        return self::returnMsg(1,['totalCount'=>$data['total'],'currentPage'=>$data['current'],'pageList'=>$data['dataList']]);
    }

    /**
     * 还原数据
     * @param string $ids
     * @return \think\response\Json
     * @throws \Exception
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function onBack($ids='')
    {
        $db_recycle = new SysRecycleModel();
        $db_recycle->backData($ids);
        return self::returnMsg(1);
    }

    /**
     * 彻底删除
     * @param string $ids
     * @return \think\response\Json
     * @throws \Exception
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function onDel($ids='')
    {
        $db_recycle = new SysRecycleModel();
        $db_recycle->delComplete($ids);
        return self::returnMsg(1);
    }
}
